package com.example.administrator.helloword.ui;

import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.nfc.Tag;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.administrator.helloword.R;
import com.example.administrator.helloword.service.MusicService;

import java.io.IOException;
import java.time.Instant;

public class IndexActivity extends AppCompatActivity implements View.OnClickListener {

    public static final String tag = "2页面";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);

        findViewById(R.id.btnClose).setOnClickListener(this);
        findViewById(R.id.btnClose2).setOnClickListener(this);
        findViewById(R.id.btnMusic).setOnClickListener(this);
    }


    @Override
    protected void onStart() {
        super.onStart();
        Log.e(tag,"onStart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e(tag,"onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e(tag,"onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e(tag,"onPause");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e(tag,"onRestart");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e(tag,"onDestroy");
    }

    @Override
    public void onClick(View v) {
       switch (v.getId()){
           case R.id.btnClose:
               finish();
               break;
           case R.id.btnClose2:
               Toast.makeText(this, "我是第二个按钮", Toast.LENGTH_SHORT).show();
               break;
           case R.id.btnMusic:
               Intent intent = new Intent(this, MusicService.class);
               startService(intent);
               break;
       }
    }
}
